import { EventDispatcher, AMEvent } from "./09-EventDispatcher";
import { triggerIdle } from "./08-AsyncPending";

interface IEventsTest {
  foo: number;
  bar: number;
}

const event = new EventDispatcher<IEventsTest>();

let value = null;

const disposer = event.on("foo", (x) => {
  value = x;
  console.log("事件被派发啦", x);
});
// console.log("disposer", disposer);

// 延时5秒 执行发布
// event.dispatch("foo", 5);
// setTimeout(() => {
//   triggerIdle();
// }, 5000);

// 立即执行的
event.dispatchImmediately("foo", 9);
event.dispatchImmediately("bar", 9);
